#include <stdio.h>
int main(){
    int year,month,day;
    scanf("%d-%d-%d",&year,&month,&day);
    if(month=1,3,5,7,8,10,12){
        if(day>31){
            printf("NO");
        }
        else{
            printf("YES");

        }
    }
    else if(month=4,6,9,11){
        if(day>30){
            printf("NO");
        }
        else{
            printf("YES");
        }
    }
    else if(month=2){
    if(((year%100)!=0&&(year%4)==0)||((year%100)==0&&(year%400)==0)){
            if(day>29){
            printf("NO");
            }
        else{
            printf("YES");
        }
    }
        else{
         if(day>28){
            printf("NO");
         }
        else{
            printf("YES");
        }
        }
    }
        return 0;
}